package com.eshore.norm.pattern.flyweight;

/**
 * 使用享元工厂来获取实例
 *
 * @author: v-chenjl62
 * @date: 2024/2/6 15:12
 */
public class Client {
    public static void main(String[] args) {
        BoxFactory instance = BoxFactory.getInstance();
        AbstractBox l = instance.getShape("L");
        l.display("gray");

        AbstractBox i = instance.getShape("I");
        i.display("bule");

        AbstractBox i2 = instance.getShape("I");
        i.display("red");

        //true，证明是同一个对象
        System.out.println(i==i2);
    }
}
